<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div class="main-content">
    <div class="box box-main">
        <form id="pointForm" model="post" action="<c:url value="/web/wuhan/unit/executeWuHanUnitEdit.action"/>"
              method="post" class="form-horizontal">
            <div class="box-body">
                <div class="form-unit">基本信息</div>
                <input type="hidden" name="id" value="${wuHanUnit.id}"/>
                <div class="row">
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span> 设备编号：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input id="unit" name="unit" class="form-control required " value="${wuHanUnit.unit}"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span> 所属机组：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input id="select_automatic" name="select_automatic" class="form-control required "/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> 所属系统：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input id="select_system" name="select_system" class="form-control required ">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="box-footer">
                    <div class="row">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i
                                    class="fa fa-check"></i> 保 存
                            </button>&nbsp;

                            <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="closeView()"><i
                                    class="fa fa-times"></i> 关 闭
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $("#pointForm").validate({
        submitHandler: function (form) {
            if (!validateMagicSuggest({
                select_automatic: '不能为空',
                select_system: '不能为空',
            })) return false;
            js.ajaxSubmitForm($(form), function (data) {
                js.showMessage(data.msg, '', data.status == Global.NO ? 'success' : 'error');
                if (data.status == Global.NO) {
                    closeView();
                    $('#dataGrid').dataGrid("refresh");
                }
            }, "json");
        }
    });

    function closeView() {
        layer.close(LayWin['wWuHanUnit']);
    }

    var select_automatic = $('#select_automatic').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/wuhan/automatic/getMeterReadingSelect.action" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        required: true,
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${wuHanUnit.meterReadingEnum}')
    });

    $(select_automatic).on('selectionchange', function(e,m){
        validateMagicReload();
    });

    var select_system = $('#select_system').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/wuhan/point/getPointSystemSelect.action" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        required: true,
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${wuHanUnit.pointSystem}')
    });
    $(select_system).on('selectionchange', function(e,m){
        validateMagicReload();
    });

</script>


